//****************************************************************
//* Copyright (c) 2004 Ford Motor Company. All Rights Reserved.
//*
//* $$Workfile:   AssemblyDao.java  $$
//* $$Revision:   1.0  $$
//* $$Author:   aponte  $$
//* $$Date:   Dec 10 2008 10:59:58  $$
//*
//*****************************************************************
package ar.com.ford.it.fullEconomics.persistence.dao;

import java.sql.Timestamp;
import java.util.Collection;
import ar.com.ford.it.fullEconomics.persistence.dto.Teesg01Plant;
import ar.com.ford.it.fullEconomics.persistence.dto.Teesp01Part;
import ar.com.ford.it.fullEconomics.persistence.dto.Tpdr018AssemblVw;
import ar.com.ford.it.webengine.persistence.PersistenceUtil;
import com.ford.it.logging.ILogger;
import com.ford.it.logging.LogFactory;
import com.ford.it.persistence.PersistenceException;
import com.ford.it.persistence.PersistenceManager;
import com.ford.it.persistence.Query;

public class AssemblyDao extends Dao {

	private static final String CLASS_NAME = AssemblyDao.class.getName();

	private static final ILogger log = LogFactory.getInstance().getLogger(
			CLASS_NAME);

	/**
	 * Busco las piezas de la parte si es que esta pertence a un conjunto
	 * 
	 * @return
	 * @throws PersistenceException
	 */
	public Collection<Tpdr018AssemblVw> findAssemblyByPartDate(
			Timestamp fechaInicio, Timestamp fechaFin,
			Teesg01Plant teesg01Plant, Teesp01Part teesp01Part)
			throws PersistenceException {

		String METHOD_NAME = "findAssemblyByPartDate";
		log.entering(CLASS_NAME, METHOD_NAME);

		Collection<Tpdr018AssemblVw> resultCol = null;
		PersistenceManager pm = null;

		pm = PersistenceUtil.getPersistenceManager();
		Query query = pm.newQuery("findAssemblyByPartDate",
				Tpdr018AssemblVw.class);

		// LSPARACI : reemplace teesp01 por cada uno de sus campos ID
		Object[] parametros = { fechaInicio, fechaFin, teesg01Plant,
				teesp01Part.getEesp01PartClassCodeC(),
				teesp01Part.getEesp01PartPrefixCodeC(),
				teesp01Part.getEesp01PartBaseCodeC(),
				teesp01Part.getEesp01PartSuffixCodeC() };

		query.setParameterArray(parametros);

		resultCol = (Collection) pm.executeQuery(query);

		log.exiting(CLASS_NAME, METHOD_NAME);
		return resultCol;
	}

}
